﻿#ifndef TRCHARTPERIODBUTTON_H
#define TRCHARTPERIODBUTTON_H

#include <map>
#include <vector>
#include <QWidget>
#include <QPushButton>
#include "TrChartTypes.h"



template<class T>
struct DisableCompare : public std::binary_function<T,T,bool>
{
   bool operator()(T a,T b)const
   {
       if(a==b)
           return false;
        return true;
   }
};


class TrChartPeriodBar : public QWidget
{
    Q_OBJECT
public:
    explicit TrChartPeriodBar(QWidget *parent = nullptr);
protected:
    TrKlinePeriod       m_trPeriod = TrKlinePeriod::KP_DAY;
public slots:
    void OnClick();
private:
    std::map<QString, TrKlinePeriod, DisableCompare<QString>>    m_mapKlinePeriod;
    std::map<int, QPushButton*> m_mapPartButtons;
    void activeBtn(TrKlinePeriod period);
signals:
    void OnChangePeriod(TrKlinePeriod);
};

#endif // TRCHARTPERIODBUTTON_H
